using System;
using System.Drawing;

namespace Minesweeper02
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	public class GraphicsItem
	{
	    //the width of item
		private int grItemWidth;
		//the height of item
		private int grItemHeight;
		//
		private int columns;
		//
		private int rows;
		//width of minemap picture
		private int width;
		//height of minemap picture
		private int height;
		public Image Img;
		private System.Drawing.Graphics g;

		public GraphicsItem(Image beginImage,int _Columns,int _Rows,int _GrItemWidth,int _GrItemHeight)
		{
			ResetAttribute(_Columns,_Rows,_GrItemWidth,_GrItemHeight);
			Img=new Bitmap(width,height);
			g=Graphics.FromImage(Img);
			ResetBeginImage(beginImage);
		}
		//
		public void ResetAttribute(int _Columns,int _Rows,int _GrItemWidth,int _GrItemHeight){
			grItemWidth=_GrItemWidth;
			grItemHeight=_GrItemHeight;
			rows=_Rows;
			columns=_Columns;
			width=columns*grItemWidth;
			height=rows*grItemHeight;
		}
		//make default image
		public void ResetBeginImage(Image beginImageItem){
			for (int x=0;x<columns;x++)
				for(int y=0;y<rows;y++)
				{
					DrawItem(beginImageItem,x,y);
				}

		}
		//method to change image of item
		public void DrawItem(Image image,int column,int row)
		{
			g.DrawImage(image,column*grItemWidth,row*grItemHeight,grItemWidth,grItemHeight);
		}
	}
}
